<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://www.goodfox.com/jsp/tags/power" prefix="p"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<script type="text/javascript">
$(function(){
	$("#role_modify_roleScope").change(function(){
		var roleScope=$("#role_modify_roleScope").val();
		if(roleScope!='0'){
			$("input[name^='role_modify_cbFun']").each(function(){
				if($(this).attr("scope")!=roleScope && $(this).attr("scope")!="0"){
					$(this).attr("checked",false);
					$(this).attr("disabled","disabled");
				}else{
					$(this).attr("disabled",false);
				}
			});
		}else{
			$("input[name^='role_modify_cbFun']").each(function(){
				$(this).attr("disabled",false);
			});
		}
	});
	if($("#role_modify_roleScope").val()!='0'){
		$("input[name^='role_modify_cbFun']").each(function(){
			if($(this).attr("scope")!=$("#role_modify_roleScope").val() && $(this).attr("scope")!="0"){
				$(this).attr("checked",false);
				$(this).attr("disabled","disabled");
			}else{
				$(this).attr("disabled",false);
			}
		});
	}else{
		$("input[name^='role_modify_cbFun']").each(function(){
			$(this).attr("disabled",false);
		});
	}
});
function roleModifySubmit(formObj){
	var funIds="";
	var funNames="";
	$("input[name^='role_modify_cbFun']").each(function(){
		if($(this).attr("checked")=="checked"){
			funIds+=$(this).attr("value")+";";
			funNames+=$(this).attr("title")+";";
		}
	});
	$("#role_modify_funIds").attr("value",funIds);
	$("#role_modify_funNames").attr("value",funNames);
	$("#role_modify_scopeName").val($("#role_modify_roleScope").find("option:selected").text());
	return validateCallback(formObj,navTabAjaxDone);
}
</script>
<div class="pageContent" style="border-left: 1px solid #B8D0D6;border-right: 1px solid #B8D0D6;">
	<div class="panelBar">
		<ul class="toolBar">
			<li><span><spring:message code="search.lnkGoModify"/>${role.roleName}</span></li>
			<li class="line">line</li>
			<c:if test="${p:isPower('/role/roleRemove.shtml',sessionScope.loginAccount)}">
			<li><a class="delete" href="<c:url value="/role/roleRemove.shtml"/>?roleId=${role.roleId}" target="ajax" rel="menuId_30"><span><spring:message code="search.btnRemove"/></span></a></li>
			</c:if>
		</ul>
	</div>
    <form id="updateRoleFrom" action="<c:url value="/role/roleModify.shtml"/>" method="post" onsubmit="return roleModifySubmit(this);">
        <table class="tableForm" cellpadding="0" cellspacing="1" width="100%" align="center">          
            <tbody>
                <tr>
                    <td>角色名称：</td>
                    <td>
			         	<input type="hidden" name="role_modify_roleId" id="role_modify_roleId" value="${role.roleId}"/>
                        ${role.roleName}
                    </td>
                    <td>适用范围：</td>
                    <td>
                        <select class="required" name="role_modify_roleScope" id="role_modify_roleScope">
                   			<option value="">--请选择--</option>
                   			<c:forEach items="${scopeList}" var="atrScope">
                   				<option value="${atrScope.atrValue}" <c:if test="${role.roleScope==atrScope.atrValue}">selected="selected"</c:if>>${atrScope.atrName}</option>
                   			</c:forEach>
                   		</select>
			         	<input type="hidden" name="role_modify_scopeName" id="role_modify_scopeName"/>
                    </td>
                </tr>
                <tr>
                    <td>系统功能：</td>
                	<td  colspan="3">
			         	<input type="hidden" name="role_modify_funIds" id="role_modify_funIds"/>
			         	<input type="hidden" name="role_modify_funNames" id="role_modify_funNames"/>
			            <table  width="100%">  
					        <tbody>
					           <c:forEach items="${funSet}" var="fun" varStatus="iFun">
					           <tr>
					               <td>
					               <input type="checkbox" name="role_modify_cbFun" id="${fun.funId}" pid="${fun.funIdParent}" value="${fun.funId}" scope="${fun.funScope}" title="${fun.funName}" class="checkboxCtrl" <c:if test="${fun.isChoise==1}">checked="checked"</c:if>>
					               ${fun.funName}
					               </td>
					           </tr>
			                   <c:forEach items="${fun.realSubFunSet}" var="subFun">
			                   <tr>
			                       <td style="padding-left:25px;">
					               		<input type="checkbox" name="role_modify_cbFun" id="${subFun.funId}" pid="${subFun.funIdParent}" value="${subFun.funId}" scope="${subFun.funScope}" title="${subFun.funName}" class="checkboxCtrl" <c:if test="${subFun.isChoise==1}">checked="checked"</c:if>>
					              		${subFun.funName}
			                       <c:if test="${subFun.realSubCount>0}">
			                        [
			                       <c:forEach items="${subFun.realSubFunSet}" var="sonFun">
					              		 <input type="checkbox" name="role_modify_cbFun" id="${sonFun.funId}" pid="${sonFun.funIdParent}" value="${sonFun.funId}" scope="${sonFun.funScope}" title="${sonFun.funName}" class="checkboxCtrl" <c:if test="${sonFun.isChoise==1}">checked="checked"</c:if>>
					               		 ${sonFun.funName}
			                       </c:forEach>
			                        ]
			                       </c:if>
			                       </td>
			                   </tr>
			                   </c:forEach>
					           </c:forEach>
					       	</tbody>
				 		</table>
			    	</td>
                </tr>
            </tbody>
        </table>
		<div class="panelBar">
	        <div class="buttonActive">
        	<c:if test="${p:isPower('/role/roleAdd.shtml',sessionScope.loginAccount)}">
	        <div class="buttonContent"><button type="submit"><spring:message code="modify.btnModify"/></button></div>
	        </c:if>
	        </div>
		</div>
    </form>
</div>